define([ "app", "jquery", "md5", "ecb", "services/UserService",
		"resources/UserResource", "resources/AddYokiKeyResource" ],
		function(app) {

			var deps = [ "$scope", "$state", "$window", "$modalInstance", "$location", "$stateParams", "UserService", "UserResource", "AddYokiKeyResource" ];

			function controller($scope, $state, $window, $modalInstance, $location, $stateParams, UserService, UserResource, AddYokiKeyResource) {
				
				
				$scope.saveKey = function() {
					AddYokiKeyResource.save($scope.keyVo).success(function(data){
						$scope.keyCreateForm.$invalid = false;
						if (data.keyId) {
							$modalInstance.close($scope.keyVo);
						}
		            });
					
				};

				$scope.close = function($scope,AddYokiKeyResource) {
					$modalInstance.close();
				};
			}
			controller.$inject = deps;
			return app.lazy.controller("AddKeyController", controller);
		});
